package com.priserve.retirement.controller;


import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.priserve.retirement.VO.ClientVo;
import com.priserve.retirement.client.delegate.AdvisorDelegate;
import com.priserve.retirement.client.exception.RetirementClientException;
import com.priserve.retirement.core.exception.RetirementCoreBusinessException;
import com.priserve.retirement.core.exception.RetirementCoreDataException;


@Controller

public class AdvisorController {

@Autowired
private AdvisorDelegate advisorDelegate;


	  @RequestMapping(value = "/advisorClients/{adv}")
	    public String getClientByAdvisor(Model model, @PathVariable String adv) {
	       
		  System.err.println("Entry to the search Method************************");
		  try {
			  
			List<ClientVo> clientList=advisorDelegate.getClientInfoByAdvisor(Long.valueOf(adv));
			model.addAttribute("clientList", clientList);
			 model.addAttribute("message", "Below is the Client Information List");
		} catch (NumberFormatException e) {
			model.addAttribute("message",e.getMessage());
			e.printStackTrace();
		
		} catch (RetirementClientException e) {
			model.addAttribute("message",e.getMessage());
			e.printStackTrace();
		}
	       
	        return "Sample";
	    }
	  
	  
	  @RequestMapping(value = "/", method = RequestMethod.GET)
	    public String testString(Model model, HttpServletRequest request) {
	       
		  System.err.println("Entry to the search Method************************");
	        //model.addAttribute("users", users);
	        model.addAttribute("search", true);
	        model.addAttribute("message", "This is a Sample Test");
	        return "Sample";
	    }
	  
	  
}
